package com.kwedding.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kwedding.dto.web.RequestGetStyleList;
import com.kwedding.dto.web.RequestStyle;
import com.kwedding.dto.web.RequestWebAddStyle;
import com.kwedding.dto.web.RequestWebDelStyle;
import com.kwedding.dto.web.RequestWebGetStyleList;
import com.kwedding.dto.web.RequestWebUpdateStyle;
import com.kwedding.dto.web.ResponseStyle;
import com.kwedding.dto.web.ResponseStyleSimpleList;
import com.kwedding.dto.web.ResponseWebStyleList;
import com.kwedding.service.web.WebStyleService;
import com.kwedding.util.BackJson;
import com.kwedding.util.JsonBackBase;
import com.kwedding.util.LoggerParent;
import com.kwedding.util.Resp_PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/rest/web/style")
@Api(tags = "WebStyle")
public class WebStyleController extends LoggerParent {

	@Autowired
	private WebStyleService webStyleService;

	@ApiOperation("添加风格信息")
	@ResponseBody
	@RequestMapping(value = "insertStyle", method = { RequestMethod.POST })
	private JsonBackBase insertStyle(@RequestBody RequestWebAddStyle webAddStyle) {
		webStyleService.insertStyle(webAddStyle);
		return BackJson.success();
	}

	@ApiOperation("后台端获取品牌风格列表（用户下拉列表选择）")
	@ResponseBody
	@RequestMapping(value = "getStyleSimple", method = { RequestMethod.POST })
	private JsonBackBase<List<ResponseStyleSimpleList>> getStyleSimple(@RequestBody RequestGetStyleList getStyleList) {
		return BackJson.successObj(webStyleService.getStyleSimple(getStyleList));
	}

	@ApiOperation("Web获取风格列表")
	@ResponseBody
	@RequestMapping(value = "getWebStyleList", method = { RequestMethod.POST })
	private JsonBackBase<Resp_PageInfo<ResponseWebStyleList>> getWebStyleList(
			@RequestBody RequestWebGetStyleList getStyleList) {
		return BackJson.successObj(webStyleService.getWebStyleList(getStyleList));
	}

	@ApiOperation("Web修改风格")
	@ResponseBody
	@RequestMapping(value = "updateStyle", method = { RequestMethod.POST })
	private JsonBackBase updateStyle(@RequestBody RequestWebUpdateStyle updateStyle) {
		webStyleService.updateStyle(updateStyle);
		return BackJson.success();
	}

	@ApiOperation("Web删除风格")
	@ResponseBody
	@RequestMapping(value = "delStyle", method = { RequestMethod.POST })
	private JsonBackBase delStyle(@RequestBody RequestWebDelStyle delStyle) {
		webStyleService.delStyle(delStyle);
		return BackJson.success();
	}

	@ApiOperation("APP爆品样片")
	@ResponseBody
	@RequestMapping(value = "getStyle", method = { RequestMethod.POST })
	private JsonBackBase<List<ResponseStyle>> getStyle(@RequestBody RequestStyle style) {
		return BackJson.successObj(webStyleService.getStyle(style));
	}
}
